package com.poet.quick.ssh.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.poet.quick.ssh.dao.GradeDao;
import com.poet.quick.ssh.entity.Grade;

@Repository("gradeDao")
public class GradeDaoImpl extends HibernateDaoSupport implements GradeDao {

	@Override
	public List<Grade> findAll() {
		String hql = "from Grade order by id";
		return super.getHibernateTemplate().find(hql);
	}

	@Override
	public List<Grade> find(String hql, Object... args) {
		return super.getHibernateTemplate().find(hql,args);
	}

	@Override
	public Grade get(Serializable id) {
		return super.getHibernateTemplate().get(Grade.class, id);
	}

	@Override
	public boolean update(Grade grade) {
		boolean updateFlag = false;
		try {
			super.getHibernateTemplate().update(grade);
			updateFlag = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return updateFlag;
	}

	@Override
	public boolean delete(Grade grade) {
		boolean deleteFlag = false;
		try {
			super.getHibernateTemplate().delete(grade);
			deleteFlag = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return deleteFlag;
	}

	@Override
	public void save(Grade grade) {
		try {
			super.getHibernateTemplate().save(grade);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
